/*
 * CalendarMenuBar.java
 */

package gui;

import java.awt.event.ActionEvent;
import java.awt.event.InputEvent;

import javax.swing.AbstractAction;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.KeyStroke;

import model.ListManager;

/**
 * CalendarMenuBar creates and displays a menubar specific to the calendar.
 * 
 * @author Sean Brown
 * @version 1.0
 */
@SuppressWarnings("serial")
public class CalendarMenuBar extends UrbanParksMenuBar {

	/**
	 * The ListManager to obtain data from.
	 */
	private final ListManager my_lm;

	/**
	 * Constructor for this JMenuBar.
	 * 
	 * @param the_login_frame
	 *            The WelcomeFrame that is associated with this menu bar.
	 * @param the_parent_frame
	 *            The JFrame that this menu bar is above.
	 * @param the_lm
	 *            ListManager to obtain data from.
	 */
	public CalendarMenuBar(final WelcomeFrame the_login_frame,
			final JFrame the_parent_frame, final ListManager the_lm) {
		super(the_login_frame, the_parent_frame, the_lm);
		my_lm = the_lm;
		add(viewMenu());
	}

	/**
	 * viewMenu method returns a menu containing all components in the "View"
	 * menu.
	 * 
	 * @return file_menu - the "File" menu.
	 */
	private JMenu viewMenu() {
		final JMenu view_menu = baseMenu("View");
		view_menu.add(new JMenuItem(new BBVolAction()));
		view_menu.add(new JMenuItem(new AllVolAction()));
		return view_menu;
	}

	/**
	 * BBVolAction is an AbstractAction that defines the actions of the
	 * "Blackballed Volunteers" function.
	 */
	private class BBVolAction extends AbstractAction {
		/**
		 * Constructor that sets the title, mnemonic, description and
		 * accelerator keys of the Action.
		 */
		public BBVolAction() {
			super("Blackballed Volunteers");
			putValue(SHORT_DESCRIPTION,
					"View all currently blackballed Volunteers.");
			putValue(MNEMONIC_KEY, Integer.valueOf('B'));
			putValue(ACCELERATOR_KEY,
					KeyStroke.getKeyStroke('B', InputEvent.ALT_MASK));
		}

		@Override
		public void actionPerformed(final ActionEvent the_event) {
			new BlackballedFrame(my_lm).start();
		}
	}

	/**
	 * AllVolAction is an AbstractAction that defines the actions of the
	 * "All Volunteers" function.
	 */
	private class AllVolAction extends AbstractAction {
		/**
		 * Constructor that sets the title, mnemonic, description and
		 * accelerator keys of the Action.
		 */
		public AllVolAction() {
			super("All Volunteers");
			putValue(SHORT_DESCRIPTION, "View all Volunteers.");
			putValue(MNEMONIC_KEY, Integer.valueOf('V'));
			putValue(ACCELERATOR_KEY,
					KeyStroke.getKeyStroke('V', InputEvent.ALT_MASK));
		}

		@Override
		public void actionPerformed(final ActionEvent the_event) {
			new AllVolunteersFrame(my_lm).start();
		}
	}
}
